Skip to content

feat(whispering): global hotkey passthrough#1673

Open
YazzinDev wants to merge 5 commits into
EpicenterHQ:mainfrom
YazzinDev:feat/global-hotkey-passthrough
Open

feat(whispering): global hotkey passthrough#1673
YazzinDev wants to merge 5 commits into
EpicenterHQ:mainfrom
YazzinDev:feat/global-hotkey-passthrough

Conversation

@YazzinDev

Copy link
Copy Markdown

feat(whispering): add global hotkey passthrough

Introduce a global shortcut passthrough mechanism that re-emits hotkeys so other applications can receive them simultaneously.

Previously, global shortcuts in Whispering were exclusive and "consuming," meaning they prevented the keyboard event from propagating to the rest of the OS. This PR adds the ability for Whispering to "re-play" these shortcuts, allowing users to use the same hotkey for both Whispering and other applications (e.g., muting Discord or OBS while starting a recording).

Technical Implementation

We implemented a robust "Unregister -> Simulate -> Re-register" loop to work around OS-level hotkey exclusivity.

1. Rust Backend (Simulation & Tracking)
Added a simulate_accelerator Tauri command that uses the enigo crate to replay the key combination. To prevent Whispering from intercepting its own simulated events (which would cause an infinite loop), we added an is_simulating atomic flag to the app state.

2. Service Layer (The Replay Loop)
The GlobalShortcutManager now manages the lifecycle of the passthrough event. When a shortcut is triggered and passthrough is enabled, it follows this sequence:

// Check if this event was triggered by our own simulation
const isSimulating = await tauriInvoke<boolean>('get_is_simulating');
if (isSimulating) return;

// 1. Execute Whispering's logic
callback(event.state);

// 2. Temporarily unregister and simulate the keypress for the OS
if (passthrough) {
    await unregister(accelerator);
    await invoke('simulate_accelerator', { accelerator });
    // Immediately re-register to keep the hotkey active
    await register({ accelerator, callback, on, passthrough });
}

3. User Interface
Added a centralized "Global Passthrough" setting to the Global Shortcuts settings page. This provides a single toggle for users who want their system-wide shortcuts to be non-consuming.

Changelog

  • Add Global Passthrough setting to allow other apps to receive shortcuts at the same time
  • Implement keyboard event simulation in the desktop backend
  • Add unit tests for global shortcut registration and passthrough logic

Closes #

Global Shortcuts Settings

PRs touching apps/api/, packages/sync/, or packages/sync-client/ require @braden-w review per CODEOWNERS.

…ey passthrough

Introduces Tauri commands simulate_accelerator and get_is_simulating to support global shortcut passthrough. Adds an is_simulating atomic flag to the application state to prevent Whispering from intercepting its own simulated keyboard events.
Enables global shortcuts to propagate to other applications by implementing a re-play mechanism. Added a global shortcuts.global.passthrough setting and updated the service layer to unregister, simulate, and re-register hotkeys when passthrough is enabled.
Exposes the global shortcut passthrough feature on the Global Shortcuts settings page. Uses standard Field components for a consistent, high-quality interface and ensures all shortcuts are synchronized immediately when the setting is toggled.
…ough

Provides a comprehensive technical specification and unit tests for the global shortcut registration logic. Includes tsconfig path aliases to support test module resolution within the whispering app.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant